0473a8003b375856290be2b8f7c993010a9e1afc,tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java,AbstractSessionExpiryTest,testSessionExpiry,#,123

Before Change


        try
        {
            HttpClient client = new HttpClient();
            client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
            client.start();
            String url = "http://localhost:" + port1 + contextPath + servletMapping;

            //make a request to set up a session on the server
            ContentExchange exchange1 = new ContentExchange(true);
            exchange1.setMethod(HttpMethods.GET);
            exchange1.setURL(url + "?action=init");
            client.send(exchange1);
            exchange1.waitForDone();
            assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus());
            String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
            assertTrue(sessionCookie != null);
            // Mangle the cookie, replacing Path with $Path, etc.
            sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
            
            //now stop the server
            server1.stop();
            
            //and wait until the expiry time has passed
            pause(inactivePeriod);
            
            //restart the server
            server1.start();            
            port1 = server1.getPort();
            url = "http://localhost:" + port1 + contextPath + servletMapping;
            
            //make another request, the session should have expired
            ContentExchange exchange2 = new ContentExchange(true);
            exchange2.setMethod(HttpMethods.GET);
            exchange2.setURL(url + "?action=test");
            exchange2.getRequestFields().add("Cookie", sessionCookie);
            client.send(exchange2);
            exchange2.waitForDone();
            assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus());
        }
        finally

After Change


            String url = "http://localhost:" + port1 + contextPath + servletMapping;

            //make a request to set up a session on the server
            Future<ContentResponse> future = client.GET(url + "?action=init");
            ContentResponse response1 = future.get();
            assertEquals(HttpServletResponse.SC_OK,response1.getStatus());
            String sessionCookie = response1.getHeaders().getStringField("Set-Cookie");
            assertTrue(sessionCookie != null);
            // Mangle the cookie, replacing Path with $Path, etc.
            sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
            
            //now stop the server
            server1.stop();
            
            //and wait until the expiry time has passed
            pause(inactivePeriod);
            
            //restart the server
            server1.start();            
            port1 = server1.getPort();
            url = "http://localhost:" + port1 + contextPath + servletMapping;
            
            //make another request, the session should have expired
            Request request = client.newRequest(url + "?action=test");
            request.getHeaders().add("Cookie", sessionCookie);
            future = request.send();
            ContentResponse response2 = future.get();
            assertEquals(HttpServletResponse.SC_OK,response2.getStatus());
        }
        finally